import Vue from 'vue'
import Router from 'vue-router'

import System from './views/system/System.vue';



import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

Vue.use(Router)

const router = new Router({
  routes: [
    // {
    //   path: '/',
    //   name: 'login',
    //   component: Login

    // },
    // {
    //   path: '/login',
    //   name: 'login',
    //   component: Login

    // },
    {
      path: '/system',
      name: 'system',
      component: System,
      children:[
        { 
          path:'showGoods',
          name:'showGoods',
          component:()=>import('./components/goods/showgoods.vue')
        },
        { 
          path:'addGoods',
          name:'addGoods',
          component:()=>import('./components/goods/addgoods.vue')
        },
        {
          path:'/system/shopslist',
          component:()=>import('./components/shops/ShopsList.vue')  //门店列表
        },
        {
          path:'/system/applyShops',
          component:()=>import('./components/shops/ApplyShops.vue') //门店申请
        },
 
      ]
    },
  
  ],
})



router.beforeEach((to, from, next) => {
  if (to.path ==='/system') {
    if (localStorage.user) {
      next()
    } else {
      confirm("请先登录");
      next(false)
    }
  }
  else {
    next()
  }
})

export default router
